package com.example.es.controller;

import java.util.concurrent.Executors;
import java.util.concurrent.LinkedBlockingQueue;
import java.util.concurrent.ThreadPoolExecutor;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.atomic.AtomicInteger;

public class TestDemo2 {
    public static void main(String[] args) {
        AtomicInteger atomicInteger = new AtomicInteger(1);
        ThreadPoolExecutor threadPoolExecutor = new ThreadPoolExecutor(5,10,3,TimeUnit.SECONDS,new LinkedBlockingQueue<>(10), Executors.defaultThreadFactory(),new ThreadPoolExecutor.AbortPolicy());
        for (int i = 0; i < 10; i++) {
            threadPoolExecutor.execute(new Runnable() {
                @Override
                public void run() {
                    Thread.currentThread().setName("tjc"+atomicInteger.getAndIncrement());
                    System.out.println(Thread.currentThread().getName());
                }
            });
        }
    }
    public static void main1(String[] args) {
        new Thread(()->{
            while (true) {
                try {
                    TimeUnit.SECONDS.sleep(1);
                    System.out.println(1);
                } catch (InterruptedException e) {
                    throw new RuntimeException(e);
                }
            }
        },"admin").start();
    }
}
